//Userlist data array for filling in info box
var userListData = [];

//DOM Ready =======================================
$(document).ready(function(){

    //Populate the user table on initial page load
    populateTable();
});

//Functions ===========================================

//添加数据到表格
function populateTable() {
    //Empty content string
    var tableContent = '';

    //jQuery AJAX使用JSON
    $.getJSON('/users/userlist', function(data){

        //把每一JSON数据item添加成行和列
        $.each(data, function(){
            tableContent += '<tr>';
            tableContent += '<td>widi<a href="#" class="linkshowuser" rel="' + this.username + '">' + this.username + '</a></td>';
            tableContent += '<td><a href="#" class="linkdeleteuser" rel="' + this._id + '">delete</a></td>';
            tableContent += '</tr>';
        });

        //把所有内容都放到HTML表格中
        $('table').html(tableContent);
    });
}